package com.web.portal.dao;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.web.portal.entity.AdvisorMeeting;
@Repository (value="advisorMeetingDao")
public class AdvisorMeetingDaoImpl extends WebportalBaseDao<AdvisorMeeting> implements AdvisorMeetingDao {
public static final Logger LOG= Logger.getLogger(AdvisorMeetingDaoImpl.class);
	public List<AdvisorMeeting> listItems(AdvisorMeeting instance) {
		// TODO Auto-generated method stub
		LOG.debug("Geeting list of Advisor meeting from database");
		try{
			@SuppressWarnings("unchecked")
			List<AdvisorMeeting> result =getSession().createQuery("from AdvisorMeeting").list();
			if(result.isEmpty()){
				LOG.debug("List is empty for Advisor meeting.............................");
			}
			return result;
		}catch(HibernateException e){
			
			LOG.debug("unable to find the item Advisor meeting......................");
			throw e;
		}
	}

	@Override
	protected void populateCriteria(
			Map<? extends Enum<?>, Object> searchCriteria, Criteria criteria) {
		if(searchCriteria.containsKey(AdvisorMeetingSearchType.ID)){
			criteria.add(Restrictions.eq("id", searchCriteria.get(AdvisorMeetingSearchType.ID)));
		}
		
	}

}
